package com.mk.admin.service.impl;

import com.mk.admin.mapper.InHospitalPatientMapper;
import com.mk.admin.model.ResultDto;
import com.mk.admin.model.entity.InHospitalPatientEntity;
import com.mk.admin.model.query.InHospitalPatientQuery;
import com.mk.admin.model.vo.InHospitalPatientVo;
import com.mk.admin.service.InHospitalPatientService;
import com.mk.admin.util.JSONCopy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class InHospitalPatientServiceImpl implements InHospitalPatientService {
   @Autowired
   private InHospitalPatientMapper inHospitalPatientMapper;
    @Override
    public ResultDto select(InHospitalPatientQuery query) {
        InHospitalPatientEntity entity= JSONCopy.copy(query,InHospitalPatientEntity.class);
        return ResultDto.data(inHospitalPatientMapper.count(entity),inHospitalPatientMapper.select(entity));
    }

    @Override
    public ResultDto add(InHospitalPatientVo inHospitalPatientVo) {
        InHospitalPatientEntity entity= JSONCopy.copy(inHospitalPatientVo,InHospitalPatientEntity.class);
        return ResultDto.data(inHospitalPatientMapper.insert(entity));
    }

    @Override
    public ResultDto update(InHospitalPatientVo inHospitalPatientVo) {
        InHospitalPatientEntity entity= JSONCopy.copy(inHospitalPatientVo,InHospitalPatientEntity.class);
        return ResultDto.data(inHospitalPatientMapper.updateById(entity));
    }

    @Override
    public ResultDto delete(int id) {
        return ResultDto.data(inHospitalPatientMapper.deleteById(id));
    }

    @Override
    public ResultDto status(int id) {
        return ResultDto.data(inHospitalPatientMapper.status(id));
    }
}
